home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s1.arc / DODISPLA.MOD < prev    next >
Text File  |  1987-08-12  |  16KB  |  451 lines

  1.  
  2. (*----------------------------------------------------------------------*)
  3. (*     Do_Display_Action  ---  interpret display escape sequence        *)
  4. (*----------------------------------------------------------------------*)
  5.  
  6. FUNCTION Do_Display_Action( Ch : CHAR; VAR Done : BOOLEAN ) : BOOLEAN;
  7.  
  8. (*----------------------------------------------------------------------*)
  9. (*                                                                      *)
  10. (*   Function: Do_Display_Action                                        *)
  11. (*                                                                      *)
  12. (*   Purpose:  Interprets and executes display escape sequence          *)
  13. (*                                                                      *)
  14. (*   Calling sequence:                                                  *)
  15. (*                                                                      *)
  16. (*      B := Do_Display_Action( Ch : CHAR ) : BOOLEAN;                  *)
  17. (*                                                                      *)
  18. (*         Ch   --- Character to act upon                               *)
  19. (*         B    --- TRUE if display action completed                    *)
  20. (*                                                                      *)
  21. (*   Calls:  Scroll                                                     *)
  22. (*           Get_Async_Integer                                          *)
  23. (*                                                                      *)
  24. (*----------------------------------------------------------------------*)
  25.  
  26. VAR
  27.    X: INTEGER;
  28.    Y: INTEGER;
  29.    B: BOOLEAN;
  30.    I: INTEGER;
  31.    C: INTEGER;
  32.  
  33. LABEL
  34.    LCursorUp,        LCursorDown,     LCursorLeft,    LCursorRight,
  35.    LClearScr,        LClearScrH,      LClearEOS,      LClearSCur,
  36.    LClearLine,
  37.    LClearEOL,        LClearLCur,      LCursorHome,    LInsertCharA,
  38.    LInsertCharB,     LInsertLineA,    LInsertLineB,   LDeleteChar,
  39.    LDeleteLine,      LStartInsert,    LEndInsert,     LNormalVideo,
  40.    LReverseVideo,    LStartBlink,     LEndBlink,      LStartUnderline,
  41.    LEndUnderline,    LStartBold,      LEndBold,
  42.    LStartDim,        LEndDim,         LReverseIndex,
  43.    LPrintLine,       LPrintPage,      LCursorPosVT52, LStartAltKey,
  44.    LEndAltKey,       LStartAutoPrint, LEndAutoPrint,  LSetTab,
  45.    LClearTab,        LDisplayChar,    LStartPrintControl,
  46.    LEndPrintControl, LIdentifyVT52,
  47.    LStartGraphicsMode,
  48.    LEndGraphicsMode, LTV950Video,     LSwallow,
  49.    LCursorPosH,      LCursorPosV,
  50.    LStartVT52HoldScreen,
  51.    LEndVT52HoldScreen,
  52.    LEnterVT100,      LEnterVT52,
  53.    LExecPCCommands,  LSendMahoneyOn,
  54.    LEnterState1,     LEnterState2,    LEnterState3,   LEnterState4,
  55.    LEnterState5,
  56.    LIndex,           LVT52HT,          LVT52LF,
  57.    LNotDone,         LEndCase;
  58.  
  59. BEGIN (* Do_Display_Action *)
  60.  
  61.    X := WhereX;
  62.    Y := WhereY;
  63.    B := TRUE;
  64.  
  65.    IF ( Ch = CHR( 0 ) ) THEN
  66.  
  67.    ELSE IF ( Ch = ^[ ) THEN
  68.       BEGIN
  69.          Escape_Mode := TRUE;
  70.          B           := FALSE;
  71.       END
  72.  
  73.    ELSE IF ( ( ORD( Ch ) < 32 ) OR Escape_Mode ) THEN
  74.       BEGIN
  75.  
  76.          I := ORD( Display_Action_Ptr[Display_Action_State]^[ Ch ] );
  77. {
  78.          CASE Display_Action_Ptr[Display_Action_State]^[ Ch ] OF
  79. }
  80.          INLINE(
  81.                  $8B/$9E/>I {  MOV     BX,[BP+>I]         ;Pick up ORD(Action)}
  82.                  /$89/$D8   {  MOV     AX,BX              ;Action}
  83.                  /$D1/$E3   {  SHL     BX,1               ;Action * 2}
  84.                  /$01/$C3   {  ADD     BX,AX              ;Action * 3}
  85.                  /$B8/>*+6  {  MOV     AX,>*+6            ;Address of first GOTO}
  86.                  /$01/$C3   {  ADD     BX,AX              ;Add offset of command}
  87.                  /$FF/$E3   {  JMP     BX                 ;Branch to proper GOTO}
  88.                );
  89.  
  90.          GOTO LCursorUp;
  91.          GOTO LCursorDown;
  92.          GOTO LCursorLeft;
  93.          GOTO LCursorRight;
  94.          GOTO LClearScr;
  95.          GOTO LClearScrH;
  96.          GOTO LClearEOS;
  97.          GOTO LClearSCur;
  98.          GOTO LClearLine;
  99.          GOTO LClearEOL;
  100.          GOTO LClearLCur;
  101.          GOTO LCursorHome;
  102.          GOTO LInsertCharA;
  103.          GOTO LInsertCharB;
  104.          GOTO LInsertLineA;
  105.          GOTO LInsertLineB;
  106.          GOTO LDeleteChar;
  107.          GOTO LDeleteLine;
  108.          GOTO LStartInsert;
  109.          GOTO LEndInsert;
  110.          GOTO LNormalVideo;
  111.          GOTO LReverseVideo;
  112.          GOTO LStartBlink;
  113.          GOTO LEndBlink;
  114.          GOTO LStartUnderline;
  115.          GOTO LEndUnderline;
  116.          GOTO LStartBold;
  117.          GOTO LEndBold;
  118.          GOTO LStartDim;
  119.          GOTO LEndDim;
  120.          GOTO LReverseIndex;
  121.          GOTO LPrintLine;
  122.          GOTO LPrintPage;
  123.          GOTO LCursorPosVT52;
  124.          GOTO LStartAltKey;
  125.          GOTO LEndAltKey;
  126.          GOTO LStartAutoPrint;
  127.          GOTO LEndAutoPrint;
  128.          GOTO LSetTab;
  129.          GOTO LClearTab;
  130.          GOTO LDisplayChar;
  131.          GOTO LStartPrintControl;
  132.          GOTO LEndPrintControl;
  133.          GOTO LIdentifyVT52;
  134.          GOTO LStartGraphicsMode;
  135.          GOTO LEndGraphicsMode;
  136.          GOTO LTV950Video;
  137.          GOTO LSwallow;
  138.          GOTO LCursorPosH;
  139.          GOTO LCursorPosV;
  140.          GOTO LStartVT52HoldScreen;
  141.          GOTO LEndVT52HoldScreen;
  142.          GOTO LEnterVT100;
  143.          GOTO LEnterVT52;
  144.          GOTO LExecPCCommands;
  145.          GOTO LSendMahoneyOn;
  146.          GOTO LEnterState1;
  147.          GOTO LEnterState2;
  148.          GOTO LEnterState3;
  149.          GOTO LEnterState4;
  150.          GOTO LEnterState5;
  151.          GOTO LIndex;
  152.          GOTO LVT52HT;
  153.          GOTO LVT52LF;
  154.  
  155.                                    (* Display character as is *)
  156.  
  157.          LDisplayChar:   Display_Character( Character_Set_Ptr^[Ch] );
  158.                          GOTO LEndCase;
  159.  
  160.                                    (* Move cursor up one line *)
  161.  
  162.          LCursorUp:      IF ( Y > 1 ) THEN
  163.                          GoToXY( X , Y - 1 );
  164.                          GOTO LEndCase;
  165.  
  166.                                    (* Move cursor down one line *)
  167.  
  168.          LCursorDown:    IF ( Y < Ansi_Last_Line ) THEN
  169.                             GoToXY( X , Y + 1 );
  170.                          GOTO LEndCase;
  171.  
  172.                                    (* Move cursor left one column *)
  173.  
  174.          LCursorLeft:    IF ( X > 1 ) THEN
  175.                             GoToXY( X - 1 , Y );
  176.                          GOTO LEndCase;
  177.  
  178.                                    (* Move cursor right one column *)
  179.  
  180.          LCursorRight:   IF ( X < Max_Screen_Col ) THEN
  181.                             GoToXY( X + 1 , Y );
  182.                          GOTO LEndCase;
  183.  
  184.                                    (* Clear screen *)
  185.          LClearScr:     BEGIN
  186.                            Scroll( 1, Ansi_Last_Line, 1, Max_Screen_Col, 0,
  187.                                    ForeGround_Color, BackGround_Color );
  188.                            FillChar( Line_Attributes, 25, 0 );
  189.                            GoToXY( X , Y );
  190.                         END;
  191.                         GOTO LEndCase;
  192.  
  193.                                    (* VT52 tabs *)
  194.  
  195.          LVT52HT:       Handle_Tab( Tab_Stops , Number_Tab_Stops );
  196.                         GOTO LEndCase;
  197.  
  198.                                    (* VT52 line feeds *)
  199.  
  200.          LVT52LF:       Do_VT52_LineFeeds( Ch );
  201.                         GOTO LEndCase;
  202.  
  203.          LEnterState1:  Display_Action_State := 1;
  204.                         GOTO LEndCase;
  205.  
  206.          LEnterState2:  Display_Action_State := 2;
  207.                         GOTO LEndCase;
  208.  
  209.          LEnterState3:  Display_Action_State := 3;
  210.                         GOTO LEndCase;
  211.  
  212.          LEnterState4:  Display_Action_State := 4;
  213.                         GOTO LEndCase;
  214.  
  215.          LEnterState5:  Display_Action_State := 5;
  216.                         GOTO LEndCase;
  217.  
  218.                                    (* Clear screen and home cursor *)
  219.          LClearScrH:     BEGIN
  220.                             Scroll( 1, Ansi_Last_Line, 1, Max_Screen_Col, 0,
  221.                                     ForeGround_Color, BackGround_Color );
  222.                             FillChar( Line_Attributes, 25, 0 );
  223.                             GoToXY( 1 , 1 );
  224.                          END;
  225.                          GOTO LEndCase;
  226.  
  227.                                    (* Clear cursor to end of screen *)
  228.          LClearEOS:      BEGIN
  229.  
  230.                             ClrEol;
  231.  
  232.                             FOR I := ( Y + 1 ) TO Ansi_Last_Line DO
  233.                                BEGIN
  234.                                   GoToXY( 1 , I );
  235.                                   ClrEol;
  236.                                   Line_Attributes[I] := 0;
  237.                                END;
  238.  
  239.                             GoToXY( X , Y );
  240.  
  241.                          END;
  242.                          GOTO LEndCase;
  243.  
  244.                                    (* Clear start of screen to current *)
  245.                                    (* cursor position                  *)
  246.          LClearSCur:     BEGIN
  247.  
  248.                             IF ( Y > 1 ) THEN
  249.                                Scroll( 1, Y - 1, 1, Max_Screen_Col, 0,
  250.                                        ForeGround_Color, BackGround_Color );
  251.  
  252.                             GoToXY( 1 , Y );
  253.  
  254.                             FOR I := 1 TO X DO
  255.                                WRITE(' ');
  256.  
  257.                             FOR I := 1 TO Y DO
  258.                                Line_Attributes[I] := 0;
  259.  
  260.                          END;
  261.                          GOTO LEndCase;
  262.  
  263.                                    (* Clear entire line *)
  264.          LClearLine:     BEGIN
  265.                             GoToXY( 1 , Y );
  266.                             ClrEol;
  267.                             GoToXY( X , Y );
  268.                             Line_Attributes[Y] := 0;
  269.                          END;
  270.                          GOTO LEndCase;
  271.  
  272.                                    (* Clear cursor to end of line *)
  273.          LClearEOL:      ClrEol;
  274.                          GOTO LEndCase;
  275.  
  276.                                    (* Clear start of line to cursor *)
  277.          LClearLCur:     BEGIN
  278.                             GoToXY( 1 , Y );
  279.                             FOR I := 1 TO X DO
  280.                                WRITE(' ');
  281.                          END;
  282.                          GOTO LEndCase;
  283.  
  284.                                    (* Move cursor to top left hand corner *)
  285.  
  286.          LCursorHome:    GoToXY( 1 , 1 );
  287.                          GOTO LEndCase;
  288.  
  289.                                    (* Reverse index *)
  290.          LReverseIndex:  BEGIN
  291.                             IF ( Y > 1 ) THEN
  292.                                GoToXY( X , Y - 1 )
  293.                             ELSE
  294.                                Scroll( 1, Max_Screen_Line - 1, 1, Max_Screen_Col,
  295.                                        -1,
  296.                                        ForeGround_Color, BackGround_Color );
  297.                          END;
  298.                          GOTO LEndCase;
  299.  
  300.                                    (* Index *)
  301.  
  302.          LIndex:         Display_Character( ^J );
  303.                          GOTO LEndCase;
  304.  
  305.          LTV950Video:    BEGIN
  306.                             Async_Receive_With_TimeOut( 5 , C );
  307.                             IF ( C <> TimeOut ) THEN
  308.                                CASE CHR( C ) OF
  309.                                   '0': ;
  310.                                   '2': ;
  311.                                   '4': ;
  312.                                   '8': ;
  313.                                END (* CASE *);
  314.                          END;
  315.                          GOTO LEndCase;
  316.  
  317.          LStartGraphicsMode : BEGIN
  318.                                  Graphics_Mode     := TRUE;
  319.                                  Character_Set_Ptr := Display_Char_Set_Ptr[2];
  320.                               END;
  321.                               GOTO LEndCase;
  322.  
  323.          LEndGraphicsMode   : BEGIN
  324.                                  Graphics_Mode     := FALSE;
  325.                                  Character_Set_Ptr := Display_Char_Set_Ptr[1];
  326.                               END;
  327.                               GOTO LEndCase;
  328.  
  329.          LIdentifyVT52   : Async_Send_String( ^[ + '/Z' );
  330.                            GOTO LEndCase;
  331.  
  332.  
  333.          LPrintPage:       Print_Screen;
  334.                            GOTO LEndCase;
  335.  
  336.                                    (* Toggle reverse video *)
  337.          LReverseVideo:    BEGIN
  338.                               I                := ForeGround_Color;
  339.                               ForeGround_Color := BackGround_Color;
  340.                               BackGround_Color := I;
  341.                               Global_Text_Attribute := 16 * ( BackGround_Color AND 7 ) + ForeGround_Color;
  342.                               TextColor( ForeGround_Color );
  343.                               TextBackGround( BackGround_Color );
  344.                            END;
  345.                            GOTO LEndCase;
  346.  
  347.          LStartDim     :   LowVideo;
  348.                            GOTO LEndCase;
  349.  
  350.          LEndDim       :   HighVideo;
  351.                            GOTO LEndCase;
  352.  
  353.                                    (* Move to screen position in VT52 format *)
  354.          LCursorPosVT52:   BEGIN
  355.  
  356.                               OldX   := NewX;
  357.                               OldY   := NewY;
  358.  
  359.                               Get_Async_Integer( NewY );
  360.                               Get_Async_Integer( NewX );
  361.  
  362.                               NewY := MAX( 1 , MIN( NewY , Max_Screen_Line - 1 ) );
  363.                               NewX := MAX( 1 , MIN( NewX , Max_Screen_Col ) );
  364.  
  365.                               GoToXY( NewX, NewY );
  366.  
  367.                            END;
  368.                            GOTO LEndCase;
  369.  
  370.          LStartAltKey:     Alt_Keypad_Mode := ON;
  371.                            GOTO LEndCase;
  372.  
  373.          LEndAltKey  :     Alt_Keypad_Mode := OFF;
  374.                            GOTO LEndCase;
  375.  
  376.          LStartAutoPrint:  Auto_Print_Mode := ON;
  377.                            GOTO LEndCase;
  378.  
  379.          LEndAutoPrint:    Auto_Print_Mode := OFF;
  380.                            GOTO LEndCase;
  381.  
  382.  
  383.          LStartPrintControl: Printer_Ctrl_Mode := ON;
  384.                              GOTO LEndCase;
  385.  
  386.          LEndPrintControl  : Printer_Ctrl_Mode := OFF;
  387.                              GOTO LEndCase;
  388.  
  389.          LStartVT52HoldScreen: Hold_Screen_Mode := ON;
  390.                                GOTO LEndCase;
  391.  
  392.          LEndVT52HoldScreen  : Hold_Screen_Mode := OFF;
  393.                                GOTO LEndCase;
  394.  
  395.          LEnterVT100:      BEGIN                (* Enter VT100 mode  *)
  396.  
  397.                               Terminal_To_Emulate := VT100;
  398.                               Done                := TRUE;
  399.  
  400.                            END;
  401.                            GOTO LEndCase;
  402.  
  403.                                         (* Indicate AutoDownload possible *)
  404.  
  405.          LSendMahoneyOn : IF Mahoney_On THEN Async_Send_String( 'EXECPC2' );
  406.                           GOTO LEndCase;
  407.  
  408.          LExecPCCommands: IF Mahoney_On THEN Exec_PC_Commands;
  409.                           GOTO LEndCase;
  410.  
  411.          LInsertCharA:
  412.          LInsertCharB:
  413.          LInsertLineA:
  414.          LInsertLineB:
  415.          LDeleteChar:
  416.          LDeleteLine:
  417.          LStartInsert:
  418.          LEndInsert:
  419.          LNormalVideo:
  420.          LStartBlink:
  421.          LEndBlink:
  422.          LStartUnderline:
  423.          LEndUnderline:
  424.          LStartBold:
  425.          LEndBold:
  426.          LPrintLine:
  427.          LSetTab:
  428.          LClearTab:
  429.          LSwallow:
  430.          LCursorPosH:
  431.          LCursorPosV:
  432.          LEnterVT52:
  433.          LNotDone       : B := FALSE;
  434.  
  435.          LEndCase       : ;
  436.  
  437.       END
  438.    ELSE
  439.       Display_Character( Character_Set_Ptr^[Ch] );
  440.  
  441.    IF B THEN
  442.       BEGIN
  443.          Do_Display_Action := TRUE;
  444.          Escape_Mode       := FALSE;
  445.       END
  446.    ELSE
  447.       Do_Display_Action := FALSE;
  448.  
  449. END   (* Do_Display_Action *);
  450.  
  451.